loadCartList();
async function loadCartList() {
	let uid = localStorage.getItem("uid");
	let {
		data
	} = await axios.get(CartListAPI, {
		params: {
			id: uid
		}
	});
	let resArr = data.data.map(
		(v) => `
		<div class="left-shop-mony">
			<div class="left-shop-name">${v.pname}</div>
			<div class="left-shop-total">${v.pprice}</div>
		</div>
	  <div class="left-bottom">
	    <div class="left-content">
	    	<dl>
	    		<dt><img src="${v.pimg}" ></dt>
	    		<dd><a href="#" onclick="delFn(${v.pid})">删除套餐</a></dd>
	    	</dl>
	    	<ul>
	    		<li>30天保价</li>
	    		<li>${v.pname}</li>
	    		<li>${v.pdesc}</li>
	    	</ul>
	    </div>
	    <div class="right-content">
	    	<span>${v.pnum}</span>
	    	<p>${v.pprice}</p>
	    </div>
	 </div>	
		`
	);
	//本句代码执行完 以后 listUl才有了内容  (请求是异步的，ul数据 最后才有的
	$(".left-shop-top").html(resArr.join(""));
}

function delFn(pid) {
	let uid = localStorage.getItem("uid");
	let token = localStorage.getItem("token");
	axios.get(productDeleteAPI, {
		params: {
			uid,
			token,
			pid: pid
		}
	}).then(function(res) {
		let obj = res.data;
		alert(obj.msg)
		loadCartList();
	});
}
